Copyright (c) 1999 Massachusetts Institute of Technology

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see https://gnu.org/licenses or write
to:
  Free Software Foundation, Inc.
  51 Franklin Street, Fifth Floor
  Boston, MA 02110-1301
  USA
------------------------------

MAG TAPE SPECS
Copied from memo from S.Cutler 2/23/72
THIS MEMO CONTAINS MANY LOWER-CASE CHARS

Bits in left half word of .OPEN call:
3.1=1,,0
    0=>	Input
    1=> Output

3.2=2,,0
    0=> Unit
    1=> Block

3.3=4,,0
    0=> ASCII
    1=> Image

3.4=10,,0
    0=> Ignore record gaps,treat them as part of the hardware
    1=> "Chunk mode."	[does not appear to be implemented any more]
	If output then write an EOR gap after each .IOT.
	If input, if user defined block IOT pointer is big enough 
	one record is read. See .IOT for details. Must be 
	opened in block mode.

3.5=20,,0
    0=> Skip to EOF on last close on read
    1=> Don't  " "  "   "     "   "   "

3.6=40,,0
    0=> Odd parity
    1=> Even parity

3.7,8=300,,0
    00=> default (800 or 1600 BPI depending on drive type)
    01=> 800 BPI		(used to be 200 BPI)
    10=> 1600 BPI		(used to be 556 BPI)
    11=> 6250 BPI		(used to be 800 BPI)

3.9=400,,0 Only meaningful for 9 track tapes
    0=> Core dump mode, 36 bit words, any density allowed.
    1=> IBM Character Mode, 32 bit words, doesn't allow 200/556 BPI

4.1,2,3=7000,,0
    0=> 2000=1024. words per record
    1=> 1000=512. WPR
    2=> 400=256. WPR
    3=> 200=128. WPR
    4=> 100=64. WPR
    5=> 40=32. WPR
    6=> 20=16. WPR
    7=> 10=8. WPR

Open error if:
	 1) Open for writing and 
		a) Open for reading on another channel
		b) Tape write locked (i.e. no ring)
		c) IBM mode and less than 800 BPI
	2) Open for reading and already open for writing on another 
	   channel
	3) Transport not on line
	4) Chunk mode and not block mode


.IOT CHNM,LOC
-------------

For standard .OPEN, this works as a standard .IOT.  If open 
in chunk mode input [not implemented any more], loc has 

	loc/  -count,,loc2

where count is a number greater than the possible number of words to 
be written into core.  The .IOT causes words to be read into core 
starting at loc2.  For each word read, the count in decreased by one.
An IOC error occurs if the count is too small to contain the 
record.

On chunk mode output, an EOR gap is written after each .IOT, 
and the tape is written after each .IOT instead of waiting for 
system buffers to fill or the channel closed. [not implemented any more]




.CLOSE CHNM,
------------

Closes the channel, releases the transport if not open on another 
channel.  Writes out all buffers in the system and writes 2 EOF 
marks if open for writing, and backs up over second one.




.STATUS CHNM,LOC
----------------

1.1-1.6=>   physical device code (15)

1.7-1.9	    mode open in

2.1=>	    System buffering capacity empty (i.e. 0=> data read from 
	    tape and not yet transferred to user by a .IOT or data 
	    .IOTed from the user to the system but not actually 
	    written onto tape or user core image.)

2.2=>	    System buffering capacity full (i.e. no core in which to 
	    allocate buffers for reading from tape.  Also too many 
	    buffers resident in system but not yet written onto either
	    tape or users core image.)

2.3=>	    1=> Beginning of tape

2.4=>	    1=> End of tape

2.5=>	    1=> 9 track, 0=> 7 track

2.6=>	    1=>IBM mode, 0=> core dump mode

2.7=>	    Transport idle (no pending command)

2.8=>       EOF (last thing seen was a tape mark)

Left half standard.




.RCHST AC,
----------

AC/  CHNM,,LOC

LOC:	0) 0,,(SIXBIT /MTn/)
	1) 0
	2) 0
	3) 0
	4) -1




.MTAPE AC,
----------

AC/  CHNM,,COMAND

COMAND/  COUNT,,FUNCTION

Right half of COMAND
	0=> Hang until all tape motions finish
	1=> Rewind
	2=> Rewind and unload  (also shreds tape leader)
	3=> Write EOR.  Writes out current system buffers even if
	    less than record size and writes an EOR gap.
	4=> Write 3 inches of blank tape
	5=> Write EOF. (Two EOF's are written automatically 
	    after a close on a channel open for writing.)
	6=> Space forward COUNT records. COUNT=0 implies 1 
	    record.  COUNT negative implies space reverse.  Stops
	    at EOF or BOT.
	7=> Space forward +- COUNT files. (Stops at BOT or 
	    logical EOT.)
	8.=> Space forward to logical EOT, back up over second 
	    EOF.
	9.=> Stop and reset the tape system.
       10.=> Set write record size to COUNT words.
       11.=> Read into AC write record size or size of last record
	     gobbled by an input IOT.

Skips if successful.

Rewind and space only if open for reading.

Write EOR, 3 inch, EOF writing only.

Stop and hang for both read and write.




Transport State Notes
--------- ----- -----

A transport turned off or off line is equivalent to not being there.

Tape can not be written unless the write enable ring is in the hub 
of the tape.

A transport can be opened by an arbitrary number of channels in
different modes, but can not be opened by more than one user, or in 
both input and output.  The device dependent bits (3.4-4.9) must be 
the same for all channels with the exception of chunk mode.


The logical end of tape (EOT) is located after two EOF's in a 
row.  A close on a channel open for writing writes two EOF's and 
then backspaces over one of them.  The .MTAPE command to go to 
the end of the tape also backspaces over the second EOF.

If the physical end of tape mark is reached while writing a record, 
the record is finished being output (there is always room for a few 
records after the reflective strip) and an IOC error is raised 
saying End of Tape.
